package com.iris.live.services.data.repositories.impl;
import com.iris.live.services.common.reconsitution.CollectionUtils;
import com.iris.live.services.data.models.CustomCarConfigureDetailModel;
import com.iris.live.services.data.repositories.ICustomCarConfigureDetailRepository;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/3/22.
 */
@Repository
public class CustomCarConfigureDetailRepositoryImpl extends BaseRepository implements ICustomCarConfigureDetailRepository {



    @Override
    public List<CustomCarConfigureDetailModel> findByCustomCarId(Integer customCarId, Integer status) {
        Map<String, Object> params = new HashMap<>();
        params.put("customCarId", customCarId);
        params.put("status", status);
        return null;//super.selectList("findByCustomCarId", params);
    }

    @Override
    public   List<Map<String,String>> findListByStoreId(String storeId, Integer status){
        String sql = "SELECT \n"  +
                        "detail.id as id, \n" +
                        "detail.custom_car_id as customCarId, \n" +
                        "detail.boutique_id as boutiqueId, \n" +
                        "detail.boutique_price as boutiquePrice," +
                        "detail.boutique_num as boutiqueNum, \n" +
                        "detail.store_id as storeId, \n" +
                        "detail.custom_name as customName, \n" +
                        "detail.discount as discount, \n" +
                        "detail.receivable as receivable, \n" +
                        "detail.net_receipts as netReceipts, \n" +
                        "detail.status as status, \n" +
                        "detail.created_time as createdTime, \n" +
                        "detail.product_num as productNum, \n" +
                        "detail.boutique_name as boutiqueName \n" +
                    "FROM \n" +
                        "custom_car_configure_detail as detail \n" +
                    "WHERE \n" +
                        "detail.store_id in(:ids) \n" +
                    "AND \n" +
                        "detail.status = :status \n" +
                    "GROUP BY \n" +
                        "detail.product_num  \n" +
                    "ORDER BY id ASC " ;
        Map<String, Object> params = new HashMap<>();
        params.put("ids", CollectionUtils.getStr4SQLINParam(CollectionUtils.ArrToCollection(storeId.split(CollectionUtils.SPLIT_STR_STRING))));
        params.put("status", status);
        return  this.getList(sql,params);
    }
}
